package cn.ecut.servletconfig;

import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.util.Enumeration;

/**
 * @author lujiapeng
 * @className TestServletConfig
 * @description TODO
 * @date 2020/9/11 10:56
 **/
public class TestServletConfig implements Servlet {
    /**
     * 在 init 方法中，可以通过 ServletConfig 对象，获取到具体的初始化参数
     * @param config
     * @throws ServletException
     */
    @Override
    public void init(ServletConfig config) throws ServletException {
        Enumeration<String> initParameterNames = config.getInitParameterNames();
        while( initParameterNames.hasMoreElements() ){
            String name = initParameterNames.nextElement();
            // 根据名字获取 初始化的值
            String value = config.getInitParameter(name);
            System.out.println( name + " : " + value );
        }
    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {

    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {

    }
}
